import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.tv.xlet.Xlet;
import javax.tv.xlet.XletContext;
import javax.tv.xlet.XletStateChangeException;

import org.havi.ui.HContainer;
import org.havi.ui.HScene;
import org.havi.ui.HStaticText;

public class Core implements Xlet,KeyListener {

	
	XletContext contexto;
	PGame PantGame;
	inicio inicio1;
	PRanking PRank;
	PAcercaDe PAcerca;
	
	//HContainer container = null;
	//HStaticText hstTexto;

	@Override
	public void initXlet(XletContext contexto) throws XletStateChangeException {
		// TODO Auto-generated method stub
		this.contexto = contexto;
//		PantGame = new PGame();
		inicio1 = new inicio();
		//PRank = new PRanking();
		//PAcerca = new PAcercaDe();
		
	}
  
	@Override
	public void pauseXlet() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void startXlet() throws XletStateChangeException {
		// TODO Auto-generated method stub
		//pantallaUno.scene.setVisible(true);
		//pantallaUno.scene.requestFocus();
		
		inicio1.scene.setVisible(true);
		inicio1.scene.requestFocus();
		
		
	}
	
	@Override
	public void destroyXlet(boolean arg0) throws XletStateChangeException {
		// TODO Auto-generated method stub
		PantGame.destruirScene();
		inicio1.destruirScene();
		
		contexto.notifyDestroyed();
	}

	@Override
	public void keyPressed(KeyEvent tecla) {
		// TODO Auto-generated method stub
		//boton azul key code = 406
				//boton amarillo key code = 405
				//boton verde key code = 404
				//boton verde key code = 403
				//boton arriba key code = 38
				//boton derecha key code = 39
				//boton abajo key code = 40
				//boton izquierda key code = 37
				//boton ok key code = 10
				
				//verde o azul
				 if  (tecla.getKeyCode() == 403){
				//	 pauseXlet();
					//PantGame.scene.setVisible(true);
					//PantGame.scene.requestFocus();
				//	PantGame.scene.repaint();
					
				}  
			/*	 if (tecla.getKeyCode() == 404){
					PRank.scene.setVisible(true);
					PRank.scene.requestFocus();
					PRank.scene.repaint();
				 }
				 if (tecla.getKeyCode() == 405){
					PAcerca.scene.setVisible(true);
					PAcerca.scene.requestFocus();
					PAcerca.scene.repaint();
				 }
				 if (tecla.getKeyCode() == 10){
					
					inicio1.scene.setVisible(true);
					inicio1.scene.requestFocus();
					inicio1.scene.repaint();
				 }*/
				 	
	}

	@Override
	public void keyReleased(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
